package com.example.multiaccountfetcher.service;

import org.springframework.stereotype.Service;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadLocalRandom;

/**
 * 数据拉取服务的模拟实现类
 */
@Service
public class MockDataFetchServiceImpl implements DataFetchService {
    
    @Override
    public CompletableFuture<Object> fetchData(String accountId, Object params) {
        return CompletableFuture.supplyAsync(() -> {
            try {
                // 模拟网络请求延迟
                int delay = ThreadLocalRandom.current().nextInt(1000, 5000);
                Thread.sleep(delay);
                
                // 模拟返回数据
                return "Data fetched for account: " + accountId + ", params: " + params + ", delay: " + delay + "ms";
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                throw new RuntimeException("Fetch data interrupted", e);
            }
        });
    }
    
}